import { api, LightningElement } from 'lwc';

import CONTACT_OBJECT_NAME from '@salesforce/schema/Contact';
import FIRST_NAME_FIELD from '@salesforce/schema/Contact.FirstName';
import LAST_NAME_FIELD from '@salesforce/schema/Contact.LastName';
import EMAIL_FIELD from '@salesforce/schema/Contact.Email';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';

export default class ContactCreator extends LightningElement {

    objectApiName = CONTACT_OBJECT_NAME;

    fields = [FIRST_NAME_FIELD, LAST_NAME_FIELD, EMAIL_FIELD];

    handleSuccess(e) {
        const evt = new ShowToastEvent({
            title: 'Contact created',
            message: 'Record ID: ' + e.detail.id,
            variant: 'success',    
        });
        this.dispatchEvent(evt);
    }

    connectedCallback() {
        console.log(this.objectApiName);   
    }
}